package edu.itla.medifacil.controllers;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.itla.medifacil.helpers.Utilities;
import edu.itla.medifacil.persistence.managers.SpecialityManager;

/**
 * Servlet implementation class Specialities
 */
public class Specialities extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private final SpecialityManager specialityManager;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Specialities() {
        super();
        this.specialityManager = new SpecialityManager();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		if("save".equals( request.getParameter("action") )){
			Map<String, String> parameters = Utilities.parametersArrayToMap( request.getParameterMap() );
			specialityManager.save(parameters);
		}
	}

}
